<?php

namespace App\Http\Admin\Services\Config;

use App\Exceptions\InvalidRequestException;
use App\Http\Services\BaseService;
use Illuminate\Support\Facades\DB;

class ConfigService extends BaseService
{
    /*
     * 设置配置
     * */
    public function setConf($key,$attributes = [])
    {
        if(is_array($attributes)){
            $attributes = json_encode($attributes);
        }

        $result = DB::table('admin_config')->where('conf_key',$key)->update([
           'conf_val' => $attributes
        ]);
        return $result;
    }

    /*
     * 获取配置
     * */
    public function getConf($key)
    {

        $result = DB::table('admin_config')->where('conf_key',$key)->first()->conf_val;

        $result =  json_decode($result,true);

        return $result;
    }




}
